<?php
use \GatewayWorker\Lib\Gateway;
class PM_d
{
    /**
     * 实时查息；认为最好是直接输出client_id最好；不走数据库
     * @param $room_id  房间ID
     * @param $db_connect  数据连接
     * @param $user_id  谁查的
     */
    public static function __index( $room_id , $db_connect , $user_id = 0 ){
        //取出房间信息
        $room_info  = $db_connect->select('*')->from('tt_room')->where("room_id= '". $room_id ."' ")->row();
        $temp       = array();
        foreach( $room_info as $key => $value ) {
            if (strstr($key, 'room_player_') != false && $value != 0 ) {
                $my_index   = PHZ_User::__get_user_Room_Index( $room_info , $value );
                $temp['zf_' . $value]   = $room_info['player_'. $my_index .'_score'];
                $temp['hx_' . $value]   = PHZ_Tools::__get_user_xpAndKanzi_Huxi( $room_id , $value , "all_get" , $user_id );
            }
        }
        foreach( $room_info as $key => $value ) {
            if (strstr($key, 'room_player_') != false && $value != 0 ) {
                $client_id = PHZ_Member::__getUserClientID( $value , $db_connect );
                if( $client_id != "" ){
                    $data = array();
                    $data['log_md']      = 32;
                    $data['log_data']    = $temp;
                    Gateway::sendToClient( $client_id , json_encode( $data ) ) ;
                }
            }
        }
    }
}